<?php
namespace api\modules\v1\controllers;

use api\modules\v1\models\userReceipt\ReceiptBank;
use yii\filters\auth\HttpHeaderAuth;
use yii\helpers\ArrayHelper;
use Yii;

/**
 * Default controller for the `v1` module
 */
class ReceiptController extends DefaultController
{
    
    public $modelClass = '';
    
    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            'authenticator' => [
                'class' => HttpHeaderAuth::className(),    //head头部验证
                'header' => 'access-token',
                'optional' => [                     //需要过滤掉不用token参数的方法
                
                ]
            ]
        ]);
    }
    
    public function actionBank($id = 0)
    {
        if (Yii::$app->request->isGet) {
            return (new ReceiptBank())->getInfo();
        }
        
        if (Yii::$app->request->isPost) {
            return (new ReceiptBank())->bind();
        }

        if (Yii::$app->request->isDelete) {
            return (new ReceiptBank())->unBind($id);
        }
    }

    public function actionBankList()
    {
        if (Yii::$app->request->isGet) {
            return (new ReceiptBank())->getList();
        }

    }


}
